<?include_once('conn.php');?>
<?include_once('inc_head.php');?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?
$act=$_GET['act'];
$series=isset($series)?$series:0;
$listTable = TABLE_C."service_area";

#/////////////////////////删除/////////////////////
if($act=='del') {	
	$id=addslashes($_GET['id']); 
	//从数据数据库
	$cmd="delete from $listTable where id=".$id;
	if(mysql_query($cmd) or die(mysql_error())){
	gourl('删除成功！',$cururl);	
	}
	exit;
}
?>

<body>
<?local("业务区域");?>
<div id="intro">
<!-------------------------------------默认状态------------------------------------->
<table width="100%" border="0"  cellpadding="2" cellspacing="0">
  <tr> 
      <td width="50%"> 
		  结果应该多一行不属于任何区域的问卷数
       </td>
      <td width="50%" align=right> 
        <?	
        $okey=get2('okey');
		$page=intval($_GET['page']);
		if($page==0){$page=1;}
		$pagesize=$news_pagesize;
		$rsStar=$page*$pagesize-$pagesize;

		//总数
		$cmd="select  id from $listTable  ";
		$rs=mysql_query($cmd) or die(mysql_error());
		$rstotal=mysql_num_rows($rs);
		
		
		$cmd="
		select c.*,COALESCE(qn.count,0) qn_count from $listTable c 
		left join (select count(id) count,id,service_area from {$TABLE}vote_qn group by service_area) qn on qn.service_area = c.id   
		union 
		select IFNULL(c.id,0) id,IFNULL(c.title,'没有服务区域') title,qn.count qn_count from {$TABLE}service_area c 
		right join (select count(id) count,id,service_area from {$TABLE}vote_qn group by service_area) qn on qn.service_area = c.id 
		order by id 
		LIMIT $rsStar,$pagesize";


		$rs=mysql_query($cmd) or die(mysql_error());	
		
		$pagetotal=ceil($rstotal/$pagesize);
		echo "<div>当前分类记录数共【".$rstotal."】条,每页显示【".$pagesize."】条 ,页码：$page/$pagetotal</div>";
		 ?>
	  </td>
          </tr>
        </table>
	<!--主内容表格-->
<form name="form_all" method=post action="?act=doall" style="margin:0px">
  <table class="table table-hover table-bordered table-striped" width="100%" border="0"  cellpadding="0" cellspacing="0" >
    <tr> 
      <th width="70"  >ID</th>
      <th width="" >标题 </th>
      <th width="150">问卷数</th>
      <th width="150">操作</th>
    </tr>
    <?
	while($row=mysql_fetch_assoc($rs)){
	  $id=$row['id'];
  ?>
    <tr  class="mytr" > 
      <td align="center" ><? echo $id ?></td>
      <td align=""> <? echo $row['title'];?></td>
      <td align="center"> <? echo $row['qn_count'];?></td>
      <td align="center" > 
		<!-- <a href="admin_vote_edit.php?id=<?echo $id?>" class="btn btn-xs btn-info" rel="floatEdit" target="_blank">编辑</a>  -->
 		<!-- <a  href="javascript:if(confirm('确定吗')){window.location='?act=del&id=<?echo $id?>&vfile=<? echo $row['videofile'];?>&imgf=<?echo $row['imagefile'];?>'}" class="btn btn-xs btn-danger">删除</a>  -->
		<a href="admin_questionneair.php?sid=<?echo $id?>" class="btn btn-xs btn-info" rel="floatEdit不启用" target="_blank">查看问卷</a> 
	</td>
    </tr>
    <?}?>
  </table>

  <!--下面的控制表格-->

	<div class="p5"><? echo turnpage2($pagesize,$rstotal);?></div>

  </form>
  
</div>
<?include('inc_foot.php');?>
</body>
</html>